home *** CD-ROM | disk | FTP | other *** search
/ QRZ! Ham Radio 3 / QRZ Ham Radio Callsign Database - Volume 3.iso / digests / tcp / 930261.txt < prev    next >
Internet Message Format  |  1994-06-04  |  11KB

  1. Date: Fri,  8 Oct 93 04:30:02 PDT
  2. From: Advanced Amateur Radio Networking Group <tcp-group@ucsd.edu>
  3. Errors-To: TCP-Group-Errors@UCSD.Edu
  4. Reply-To: TCP-Group@UCSD.Edu
  5. Precedence: Bulk
  6. Subject: TCP-Group Digest V93 #261
  7. To: tcp-group-digest
  8.  
  9.  
  10. TCP-Group Digest            Fri,  8 Oct 93       Volume 93 : Issue  261
  11.  
  12. Today's Topics:
  13.                      KA9Q SMTP... (& SMTP spec..)
  14.                         Raising the S/N ratio
  15.                           SMTP transparency
  16.  
  17. Send Replies or notes for publication to: <TCP-Group@UCSD.Edu>.
  18. Subscription requests to <TCP-Group-REQUEST@UCSD.Edu>.
  19. Problems you can't solve otherwise to brian@ucsd.edu.
  20.  
  21. Archives of past issues of the TCP-Group Digest are available
  22. (by FTP only) from UCSD.Edu in directory "mailarchives".
  23.  
  24. We trust that readers are intelligent enough to realize that all text
  25. herein consists of personal comments and does not represent the official
  26. policies or positions of any party.  Your mileage may vary.  So there.
  27. ----------------------------------------------------------------------
  28.  
  29. Date: Thu, 07 Oct 93 10:02 PDT
  30. From: Michael Stein                        <OSYSMAS@MVS.OAC.UCLA.EDU>
  31. Subject: KA9Q SMTP... (& SMTP spec..)
  32. To: tcp-group@UCSD.EDU
  33.  
  34. By my reading of the SMTP specs, the null character ' 0'
  35. (or 0x00) is valid in the user data.  So SMTP data can't
  36. be processed as C strings without loosing the tail ends
  37. of lines...
  38.  
  39. ------------------------------
  40.  
  41. Date: Thu, 7 Oct 93 08:41:10 EST
  42. From: "Ashok Aiyar" <ashok@biochemistry.BIOC.CWRU.Edu>
  43. Subject: Raising the S/N ratio
  44. To: n4yyh@wa2hee.ampr.org
  45.  
  46. On Wed, 6 Oct 93 23:46:05 EDT, Ross Patterson wrote:
  47.  
  48. >
  49. >     else if (*p != '.')
  50. >           p--;
  51. >
  52. >thus removing the first of a pair of periods that start a line (i.e. 
  53. >"<CRLF>.."). 
  54. >
  55. >Note: The above suggestions are untested.  That would be cheating. 
  56. >Software is a thing of the mind.
  57.  
  58. :-)
  59.  
  60. Works very well.  Thanks!
  61.  
  62. Ashok
  63.  
  64. --
  65. Ashok Aiyar                        Email: ashok@biochemistry.cwru.edu
  66. Department of Biochemistry           Tel: (216) 368-3300
  67. CWRU School of Medicine              Fax: (216) 368-4544
  68. MIME Enclosures OK
  69.  
  70. ------------------------------
  71.  
  72. Date: Fri, 8 Oct 93 01:06:38 EDT
  73. From: "Barry Siegfried" <k2mf@k2mf.ampr.org>
  74. Subject: SMTP transparency
  75. To: tcp-group@ucsd.edu
  76.  
  77. Hi, all...
  78.  
  79. Regarding the fix to the SMTP server which Ross Patterson, N4YYH
  80. provided to delete the leading dot on any line beginning with two
  81. dots, I have a somewhat different analysis of the problem, and I'd
  82. like to offer what I've come with to the group.
  83.  
  84. I'm the first to admit that I am no expert in interpreting RFCs, so
  85. my premise might be faulty.  But here goes anyway...
  86.  
  87. Again reading page 41, section 4.5.2 of RFC 821 on SMTP dot handling
  88. (as quoted by Ross):
  89.  
  90.    "2. When a line of mail text is received by the receiver-SMTP it
  91.     checks the line.  If the line is composed of a single period it
  92.     is the end of mail.  If the first character is a period and there
  93.     are other characters on the line, the first character is deleted."
  94.  
  95. (Note that the above doesn't specify just precisely where this first
  96. dot character comes from, that is, was it originally in the mail, or
  97. was it put there by the sending SMTP client?)
  98.  
  99. and,
  100.  
  101. again reading page 55, section 5.2.11 of RFC 1123 "Transparency:
  102. RFC-821 Section 4.5.2" (as quoted by Ross):
  103.  
  104.    "Implementors MUST be sure that their mail systems ALWAYS add and
  105.     delete periods to ENSURE MAIL TRANSPARENCY."  (my emphasis added)
  106.  
  107. I interpret this to mean, as Ross did:
  108.  
  109. > It's not just the extra period - it's any leading (but not standalone)
  110. > period.  A conforming sender-SMTP will ALWAYS (my emphasis) send doubled
  111. > leading periods, but the spec is clear that the leading period gets
  112. > removed regardless of what follows it.  The sole exception is the
  113. > "<CRLF>.<CRLF>" end-of-mail sequence.
  114.  
  115. But why not a stand alone dot?  If I deliberately put a stand alone dot,
  116. or multiple dots at the beginning of lines in my messages, I want them
  117. delivered to the other end precisely the way I entered them (therein
  118. the definition of "transparency").
  119.  
  120. Upon checking just precisely what the original code in the SMTP server
  121. does, I came up with these results:
  122.  
  123. Original code
  124. -------------
  125.         else if (!(*p == '.' && *(p+1) == '\0'))
  126.                 p--;
  127.  
  128. Definition
  129. ----------
  130. Delete the first dot on a line if it is immediately followed by a
  131. second dot, and then a CRLF.
  132.  
  133. Results:
  134.  
  135.  Sent line                        Received line
  136.  ---------                        -------------
  137.  .<any other data><CRLF>    -->  .<any other data><CRLF>
  138.  .<CRLF>                    -->  .<CRLF>
  139.  
  140.  ..<any other data><CRLF>   -->  ..<any other data><CRLF>
  141.  ..<CRLF>                   -->  .<CRLF>  <-- this case only is reduced !
  142.  
  143.  ...<any other data><CRLF>  -->  ...<any other data><CRLF>
  144.  ...<CRLF>                  -->  ...<CRLF>
  145.  
  146. etc.
  147.  
  148. Note that the reason this one case above gets reduced by one dot,
  149. and the others don't, is because the SMTP server has no way of
  150. determining whether the two dots comprising that single line are
  151. there as a result of being originally placed in the message, or
  152. whether they exist because the SMTP client added a dot in a line
  153. containing only a single dot!
  154.  
  155. Now, in contrast to the original code, the N4YYH revised code in the
  156. SMTP server will give these results:
  157.  
  158. N4YYH code
  159. ----------
  160.         else if (*p != '.')
  161.                 p--;
  162.  
  163. Definition
  164. ----------
  165. Delete the first dot on a line if it is immediately followed by a
  166. second dot (no other requirement).
  167.  
  168. Results:
  169.  
  170.  Sent line                        Received line
  171.  ---------                        -------------
  172.  .<any other data><CRLF>    -->  .<any other data><CRLF>
  173.  .<CRLF>                    -->  .<CRLF>
  174.  
  175. (every case below is reduced by one dot) !
  176.  
  177.  ..<any other data><CRLF>   -->  .<any other data><CRLF>
  178.  ..<CRLF>                   -->  .<CRLF>
  179.  
  180.  ...<any other data><CRLF>  -->  ..<any other data><CRLF>
  181.  ...<CRLF>                  -->  ..<CRLF>
  182.  
  183. etc.
  184.  
  185. Actually, Ross was on the right track when he said:
  186.  
  187. > It would seem the thing to do is to delete:
  188. >
  189. >       else if (!(*p == '.' && *(p+1) == '\0'))
  190. >               p--;
  191. >
  192. > thus removing any period that starts a line (i.e. "<CRLF>.").
  193.  
  194. And that's probably where he should have stopped, since a careful
  195. examination of the problem will indicate that the problem is
  196. actually elsewhere!
  197.  
  198. Here's my take on this:
  199.  
  200. An examination of the corresponding code in the SMTP client indicates
  201. that a dot is added only to lines that consist of a single dot,
  202. followed by <CRLF>, and that is where the REAL problem is !
  203.  
  204. What is needed in concert with deletion of the code above in the SMTP
  205. server, is a corresponding fix to the SMTP client to make sure that an
  206. extra dot is ALWAYS added to any line beginning with a dot, regardless
  207. of whatever other data follows it, which will then ALWAYS be removed
  208. by the SMTP server (again, therein the definition of "transparency").
  209. The combination of these two operations, will then cause all lines
  210. beginning with dots to be passed "transparently" from SMTP client
  211. to server, and all original dots at the beginnings of lines will be
  212. preserved in messages.
  213.  
  214. So, in contrast to what Ross did, here are the corresponding code
  215. fragments which I have implemented in my own copies of SMTPSERV.C
  216. and SMTPCLI.C:
  217.  
  218. SMTPSERV.C
  219. ----------
  220. static int
  221. getmsgtxt(mp)
  222. struct smtpsv *mp;
  223.  
  224.         /* Check for end of message i.e. a "." or escaped ".." */
  225.         if (*p == '.') {
  226.  
  227.                 /* This IS the end of the message (i.e.
  228.                  * "<CRLF>.<CRLF>") - K2MF 10/93
  229.                 if (*++p == '\0') {
  230.  
  231.                         << End of message routines execute here >>
  232.  
  233.                         return 0;
  234.  
  235.                 /* This IS NOT the end of message - K2MF 10/93 */
  236.  
  237.                 /* Original code - this removes the first dot on any
  238.                  * line consisting solely of two dots (i.e.
  239.                  * "<CRLF>..<CRLF>") - This is not transparent ! -
  240.                  * K2MF - 10/93
  241.                 } else if (!(*p == '.' && *(p+1) == '\0')) */
  242.  
  243.                 /* N4YYH mod - this removes the first dot on any line
  244.                  * beginning with two dots regardless of what follows
  245.                  * (i.e. "<CRLF>..<any other data><CRLF>") - This is
  246.                  * not transparent ! - K2MF 10/93
  247.                 } else if (*p != '.') */
  248.  
  249.                 /* Since the SMTP client is required to make the mail
  250.                  * "transparent", and to insert an extra dot in front
  251.                  * of the first character on any line which begins
  252.                  * with a dot, it is best to simply drop the first
  253.                  * dot, because by definition, the SMTP client has
  254.                  * inserted it in front of an existing dot (see the
  255.                  * corresponding fix to smtpsendfile() in SMTPCLI.C)
  256.                  * - K2MF 10/93
  257.                         p--; */
  258.   }
  259.         }
  260.         << continue >>
  261.  
  262. SMTPCLI.C
  263. ---------
  264. static int
  265. smtpsendfile(cb)
  266. register struct smtpcli *cb;
  267.  
  268.         /* Escape a single '.' character at the beginning of a line */
  269.  
  270.         /* Original code - this inserts a dot on any line consisting
  271.          * solely of one dot (i.e. "<CRLF>.<CRLF>") - This is not
  272.          * transparent ! - K2MF 10/93
  273.         if(strcmp(cb->buf,".\n") == 0) */
  274.  
  275.         /* Since the SMTP client is required to make the mail
  276.          * "transparent", and to insert an extra dot in front
  277.          * of the first character on any line which begins with
  278.          * a dot, it is best to insert a dot on any line which
  279.          * begins with a dot (see the corresponding fix to
  280.          * getmsgtxt() in SMTPSERV.C) - K2MF 10/93 */
  281.         if(*(cb->buf) == '.')
  282.  
  283.                 usputc(cb->s,'.');
  284.         usputs(cb->s,cb->buf);
  285.  
  286. << continue >>
  287.  
  288. Definition
  289. ----------
  290. The SMTP client will always add a dot in any line which begins
  291. with a dot, and the SMTP server will always delete the first
  292. character of a line if it is a dot.
  293.  
  294. This would seem to preserve "transparency".
  295.  
  296. Now of course, until all NOS SMTP clients and servers have these
  297. mods in them, when a modified SMTP client talks to an unmodified
  298. SMTP server, most lines beginning with a dot will have an extra
  299. dot in the received message, and, when an unmodified SMTP client
  300. talks to a modified SMTP server, most lines beginning with a dot
  301. will be reduced by one dot in the received message.
  302.  
  303. 73, de Barry, K2MF >>
  304.  
  305. ^________________________________]
  306. ^      Barry Siegfried, K2MF     ]
  307. ^   AmprNet: k2mf@k2mf.ampr.org  ]
  308. ^  InterNet: k2mf@wg2w.njit.edu  ]
  309. ^\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\]
  310.  
  311. ------------------------------
  312.  
  313. End of TCP-Group Digest V93 #261
  314. ******************************
  315. ******************************
  316.